﻿using AutoMapper;
using BCGM.MedicalWisdom.IServices;
using BCGM.MedicalWisdom.Model.Models.Doctors;
using BCGM.MedicalWisdom.Model.ViewModels.DoctorDTO;
using BCGM.MedicalWisdom.Repository.BASE;
using BCGM.MedicalWisdom.Services.BASE;
using System.Threading.Tasks;

namespace BCGM.MedicalWisdom.Services
{
    public class DoctorUsersServices : BaseServices<DoctorUsers>,IDoctorUsersServices
    {
        private readonly IBaseRepository<DoctorUsers> _dal;
        private readonly IMapper  _mapper; //AutoMapper接口需要依赖注入
        public DoctorUsersServices(IBaseRepository<DoctorUsers> dal, IMapper mapper)
        {
            this._dal=dal;
            base.BaseDal=dal;
            _mapper=mapper;
        }

        public async Task<int> UserAdds(DoctorUsersDTO input)
        {
            DoctorUsers doctorUseres = _mapper.Map<DoctorUsers>(input);
            //账号生成使用手机号
            doctorUseres.Id=doctorUseres.Id;
            return await _dal.Add(doctorUseres);
        }

    }
}
